import request from '@/utils/request'

// 获取验证码
export function getCodeImg() {
  return request({
    url: '/captchaImage',
    method: 'get',
    headers: {
      isToken: false
    },
    timeout: 20000
  })
}

// 用户注册
export function register(data) {
  return request({
    url: '/noAuth/register',
    method: 'post',
    data: data,
    headers: {
      isToken: false
    }
  })
}

// 用户登录
export function login(data) {
  return request({
    url: '/login',
    method: 'post',
    data: data
  })
}

// 获取用户信息
export function getUserInfo() {
  return request({
    url: '/getInfo',
    method: 'get'
  })
}

// 用户登出
export function logout() {
  return request({
    url: '/logout',
    method: 'post'
  })
}

// 默认导出对象
const authAPI = {
  getCodeImg,
  register,
  login,
  getUserInfo,
  logout
}

export default authAPI